<!DOCTYPE html>

<html lang="zh-cn" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="format-detection" content="telephone=no" />
    <title>预约体检</title>
    <link href="../css/ekang.css" rel="stylesheet" />
    <link href="../css/chooseDoctor_css/style.css" rel="stylesheet" />
    <link href="../css/chooseDoctor_css/styleProgress.css" rel="stylesheet" />

    <style>
        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            font-size: 14px;
            margin: 0;
            padding: 0;
            color: #6C6C6C;
        }

        .reservation {
            background-color: #ffffff;
            border-bottom: solid 1px #e6e6e6;
        }

        .reservation_title {
            padding: 7px;
            color: #43af80;
            font-size: 13px;
            border-bottom: solid 1px #e6e6e6;
        }

        .reservation_title img{
            width: 12px;
            height: 12px;
            margin-right:5px;

        }
        .reservation_table {
            text-align: center;
            padding: 7px;
        }

        #reservation_table a {
            /* color: #FFFFFF;*/
        }

        .special_border {
            border-collapse: inherit;
            border-spacing: 1px;
        }

        .reservation table {
            width: 100%;
            background-color: #e6e6e6;
        }

        .reservation td {
            background-color: white;
            text-align: center;
            width: 40px;
            height: 40px;
        }

        .reservation .font {
            font-size: 11px;
            color: #4a4a4a;
        }

        .reservation .num {
            font-size: 7px;
            color: #939393;
        }

        .reservation .title {
            font-size: 11px;
        }

        table {
            width: 100%;
        }

        .reservation_time{
            font-family:STHeiti;
            font-weight: inherit;
            text-align: center;
            font-size: 13px;
            margin-top: 10px;
            color: #79807d;
            font-style: inherit;
        }

        .commment_list img{
            width: 15%;
            margin-left: 10px;
            margin-top: 10px;
            float: left;
        }


        .backView {
            width: 100%;
            height: 50px;
            margin-top: 10px;
            background-color: #fff;
            border-top: 1px solid #dddddd;
            border-bottom: 1px solid #dddddd;
            list-style-type: none;
        }

        .li-title {
            position: absolute;
            color: #333333;
            font-size: 14px;
            left: 12px;
            line-height: 50px;
            /*font-weight: bold;*/
        }

        .choose {
            float:left;
            margin:0 10px;
            display:inline;
            color: #333333;
            font-size: 14px;
            margin-top: 13px;
            height: 24px;
            line-height: 24px;
            border-radius: 12px;
        }

        .choose-on {
            background-color: #43af80;
            color: #fff;
        }

        #nures_time ::-webkit-input-placeholder { color: #333333;text-align: right }

        ::-webkit-input-placeholder { color: #b3b3b3;}
        input:-moz-placeholder { color: #b3b3b3; }

        .li-text {
            position: absolute;
            color: #b3b3b3;
            border: none;
            outline: none;
            font-size: 15px;
            line-height: 45px;
            right: 0;
            width: 60%;
            text-align: right;
            background-color: rgba(102, 102, 102, 0);
        }

        .li-title-detail {
            position:absolute;
            color: #b3b3b3;
            border: none;
            outline: none;
            font-size: 15px;
            right: 0;
            text-align: left;
            /*background-color:#009688;*/
            width: 94%;
            height: 79px;
            left: 10px;
            top: 5px;
        }

        .icon-right {
            background: url(../img/right_24.png) no-repeat 98% center transparent;
            background-color: #fff;
            background-size: 12px 12px;
        }

        .tabs-choose {
            /*height: 50px;*/
            line-height: 50px;
            position: absolute;
            background-color: rgba(255, 255, 255, 0);
            right: 25px;
            color: #333333;
        }

        .tabs-choose div {
            background-origin: content-box;
            font-size: 14px;
            text-align: right;
        }
    </style>

</head>
<body>

<!--// 导航条-->
<div style="width: 100%;height: 45px;margin-top: -45px;background-color: #38a16d;position: fixed;z-index: 10000">
    <h1 class="nav-title" style="font-size: 18px;line-height: 45px">预约体检</h1>
    <img src="../img/BackIcon.png" alt="返回" class="nav-backImg" id="back"/>
</div>

<ui>
    <li id="hospitalDetail" class="backView icon-right" style="margin-top: 45px">
        <span class="li-title" id="chooseText">选择医院</span>
    </li>
</ui>

<!-- 预约日期 -->
<div class="reservation" style="margin-top: 10px;border-top: 1px solid #e6e6e6">
    <div class="reservation_title">
        <img src="../img/doctorDetail/docter/矩形-3@2x.png">
        就诊时间
    </div>

    <!--滚动-->
    <div class="container" style="height: 210px">
        <section class="sample" data-slidizle>

            <ul class="slider-content" data-slidizle-content>

                <li class="slider-item">

                    <div class="reservation_time" id="table_time_01">
                        日期
                    </div>
                    <div class="reservation_table">
                        <table id="table01" class="special_border" cellspacing="1" cellpadding="5">
                            <tr>
                                <td class="t_l_radius"><img src="../img/doctorDetail/calendar.png" width="18" height="18" /></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td class="t_r_radius"></td>
                            </tr>
                            <tr>
                                <td class="title">上午</td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                            </tr>
                            <tr>
                                <td class="title">下午</td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                            </tr>

                        </table>
                    </div>
                </li>

                <li class="slider-item">

                    <div class="reservation_time" id="table_time_02">
                        日期
                    </div>
                    <div class="reservation_table">
                        <table id="table02" class="special_border" cellspacing="1" cellpadding="5">
                            <tr>
                                <td class="t_l_radius"><img src="../img/doctorDetail/calendar.png" alt="" width="18" height="18" /></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td class="t_r_radius"></td>
                            </tr>
                            <tr>
                                <td class="title">上午</td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                            </tr>
                            <tr>
                                <td class="title">下午</td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                            </tr>

                        </table>
                    </div>
                </li>


                <li class="slider-item">
                    <div class="reservation_time" id="table_time_03">
                        日期

                    </div>
                    <div class="reservation_table">
                        <table id="table03" class="special_border" cellspacing="1" cellpadding="5">
                            <tr>
                                <td class="t_l_radius"><img src="../img/doctorDetail/calendar.png" width="18" height="18" /></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td class="t_r_radius"></td>
                            </tr>
                            <tr>
                                <td class="title">上午</td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                            </tr>
                            <tr>
                                <td class="title">下午</td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                            </tr>

                        </table>
                    </div>
                </li>

            </ul>

            <!-- 下面三个点 -->
            <ul class="slider-navigation" data-slidizle-navigation>
                <!-- automatically generated navigation -->
            </ul>

        </section>
    </div>

</div>

<!--// 列表-->
<ui>
    <li class="icon-right backView" id="choosePeople">
        <span class="li-title">就诊患者</span>
        <div id="user_name" class="tabs-choose text-center">点击选择</div>
    </li>
    <li class="backView">
        <span class="li-title">备用联系人</span>
        <input type="number" id="mobile" placeholder="请输入备用联系人手机号" class="li-text"/>
    </li>
    <li class="icon-right backView">
        <span class="li-title">诊疗金</span>
        <div id="diagnosis_money"  class="tabs-choose text-center">点击选择</div>
    </li>
</ui>
<p style="font-size: 12px;margin-left: 10px;margin-top:10px;color: #999999"><span style="font-size: 13px;color: rgb(102, 102, 102)">服务说明</span><br/>陪珍的服务费价格为180元一次，服务范围包括帮排队、帮跑腿、帮您各种就诊相关所需</p>
<br/><br/>

<div style="position: fixed;display: flex;height: 49px;width: 100%;background-color: #393d3b;bottom: 0">
    <div style="position: absolute;left: 10px;line-height: 49px;font-size: 13px;color: #fff">服务费：<span id="money_num">299</span>元</div>
    <div id="submitOrder" style="position: absolute;right: 0;width: 105px;height: 49px;background-color: #26d086;font-size: 16px;color: #fff;text-align: center;line-height: 49px">立即预约</div>
</div>

<script src="../js/jquery-1.10.2.js" type="text/javascript"></script>
<script src="../js/ekang.js"></script>
<script src="../js/jquery.slidizle.js"></script>
<script src="../js/jquery.cookie.js"></script>

<script>

    $(function () {
        //初始化滚动条
        $('[data-slidizle]').slidizle({
            beforeChange : function(api) {
                console.log('previous', api.getPreviousSlide().index());
                console.log('current', api.getCurrentSlide().index());
                console.log('next', api.getNextSlide().index());
                console.log('previous active', api.getPreviousActiveSlide().index());
            }
        });

        var appointment_time;
        var time;

        // 诊疗金数据
        var diagName;
        var diagId;

        var hospital_id = getQueryString("hospitalId");

        // 医院
        $('#chooseText').html($.cookie("examination_hospital"));


        // 用户
        if($.cookie("username")){
            $('#user_name').html($.cookie("username"));
        }

        var sever = {
            getworktime: function () {
                $.ajax({
                    type: 'GET',
                    url: textUrl + '/index/getWorkTime',
                    data: {         // 需要于客户端同步
                        uid : ''
                    },
                    dataType: 'jsonp',
                    jsonp: 'callback',
                    success: function (result) {
                        if (result.ret == 0) {

                            ///////医生排版信息
                            var workTime = result.data;

                            var now_data = workTime.now_week;

                            for (var now_index in now_data) {

                                var obj = now_data[now_index];

                                loadData("table01", obj, parseInt(now_index) + parseInt(1));

                                if(now_index==0){

                                    $("#table_time_01").text(obj.current_year);
                                }
                            }

                            var next_data = workTime.next_week;
                            for (var next_index in next_data) {


                                var obj = next_data[next_index];

                                loadData("table02", obj, parseInt(next_index) + parseInt(1));

                                if(next_index==0){

                                    $("#table_time_02").text(obj.current_year);
                                }

                            }


                            var next_next_data = workTime.next_next_week;
                            for (var next_next_index in next_next_data) {

                                var obj = next_next_data[next_next_index];

                                loadData("table03", obj, parseInt(next_next_index) + parseInt(1));

                                if(next_next_index==0){

                                    $("#table_time_03").text(obj.current_year);
                                }
                            }
                        } else {
                            alert(result.msg);
                        }
                    }
                });
            },
            getPrice: function () {
                $.ajax({
                    type: 'GET',
                    url: textUrl + '/diagnosis/getPrice/',
                    data: {         // 需要于客户端同步
                        hospital_id : hospital_id,
                        appointment_type : '5',
                        type : '6',
                        uid : $.cookie("local_userId")
                    },
                    dataType: 'jsonp',
                    jsonp: 'callback',
                    success: function (result) {
                        if (result.ret == 0) {
                            $('#money_num').html(result.data.physical_price);

                            // 诊疗金
                            if($.cookie("dia_name")){
                                diagName = $.cookie("dia_name");
                                diagId = $.cookie("dia_id");
                                $('#diagnosis_money').html(diagName+"元诊疗金");
                                $('#money_num').html(parseInt($('#money_num').text())-parseInt(diagName));
                                // 删除本地保存
                                $.cookie('dia_name', "", { expires: 7,path: '/' });
                                $.cookie('dia_id', "", { expires: 7,path: '/' });
                            }else{
                                $('#diagnosis_money').html();
                            }
                        }else {
                            alert(result.msg);
                        }
                    }
                });
            },
            subOrder: function () {
                $.ajax({
                    type: 'GET',
                    url: textUrl + '/diagnosis/submitOrder/',
                    data: {         // 需要于客户端同步

                        family_id : $.cookie("userId"),
                        hospital_id : hospital_id,
                        appointment_type : '5',
                        type : '6',
                        uid : $.cookie("local_userId"),
                        appointment_time: $.myTime.DateToUnix("2016-"+appointment_time),
                        mobile : $('#mobile').val(),
                        day_time : time,
                        coupon_id : diagId
                    },
                    dataType: 'jsonp',
                    jsonp: 'callback',
                    success: function (result) {
                        if (result.ret == 0) {
                            var order = result.data.order_id;
                            location.href = "../hospital_nurse/nurse_payorder.html?order_id="+order;
                        } else {
                            alert(result.msg);
                        }
                    }
                });
            }
        };

        // 立即预约
        $('#submitOrder').on('click', function () {

            if($('#mobile').val().length == 0){
                alert("请输入备用联系人手机号");
                return;
            }
            if(!(/^1[3|4|5|8][0-9]\d{4,8}$/.test($('#mobile').val()))){
                alert("请输入正确的手机号");
                document.mobileform.mobile.focus();
                return false;
            }
            if(!appointment_time){
                alert("请选择就诊时间");
                return;
            }
            sever.subOrder();
        });

        /**
         * 加载排班表数据
         */
        function loadData(tableId, obj, index) {

            //设置表头日期
            $("#" + tableId + " tr:eq(0) td:eq(" + index + ")").html('<span class="font">' + obj.week_text + '</span><br/><span class="num">' + obj.date + '</span>');

            //设置上午
            if (obj.am == 0) {
                $("#" + tableId + " tr:eq(1) td:eq(" + index + ")").css("background-color", "#fff");
                $("#" + tableId + " tr:eq(1) td:eq(" + index + ")").html("");
            } else {
                $("#" + tableId + " tr:eq(1) td:eq(" + index + ")").css("background-color", "#fff");
                $("#" + tableId + " tr:eq(1) td:eq(" + index + ")").on('click', function () {
                    $('.reservation_table table td').css("background-color", "#fff");
                    $(this).addClass($(this).css("background-color", "#43AF80"));
                    $(this).html('<span class="font" style="color: #fff">' + obj.week_text + '</span><br/><span class="num" style="color: #fff">上午</span>');
                    appointment_time = obj.date;
                    time = 1;
                });
            }

            //设置下午
            if (obj.pm == 0) {
                $("#" + tableId + " tr:eq(2) td:eq(" + index + ")").css("background-color", "#fff");
                $("#" + tableId + " tr:eq(2) td:eq(" + index + ")").html("");
            } else {
                $("#" + tableId + " tr:eq(2) td:eq(" + index + ")").css("background-color", "#fff");
                $("#" + tableId + " tr:eq(2) td:eq(" + index + ")").on('click', function () {
                    $('.reservation_table table td').css("background-color", "#fff");
                    $(this).addClass($(this).css("background-color", "#43AF80"));
                    $(this).html('<span class="font" style="color: #fff">' + obj.week_text + '</span><br/><span class="num" style="color: #fff">下午</span>');
                    appointment_time = obj.date;
                    time = 2;
                });
//                $("#" + tableId + " tr:eq(2) td:eq(" + index + ")").html('<a href="doctor_appointment.html?am=2&day='+obj.day+'&time='+obj.date+'" style="color: white;font-size: 11px">立即<br/>预约</a>');
            }

        }

        sever.getPrice();
        sever.getworktime();


        if($.cookie("severMoney")){
            var money = $.cookie("severMoney");
            $('#money_num').html(money);

            // 删除本地保存
            $.cookie('severMoney', "", { expires: 7,path: '/' });
        }

        // 诊疗金
        if($.cookie("dia_name")){
            diagName = $.cookie("dia_name");
            diagId = $.cookie("dia_id");
            $('#diagnosis_money').html(diagName+"元诊疗金");
            $('#money_num').html(parseInt($('#money_num').text())-parseInt(diagName));
//            // 删除本地保存
//            $.cookie('dia_name', "", { expires: 7,path: '/' });
//            $.cookie('dia_id', "", { expires: 7,path: '/' });
        }else{
            $('#diagnosis_money').html();
        }


        $('#diagnosis_money').on('click', function () {
            var  money;
            if(diagName){
                money = parseInt($('#money_num').text())+parseInt(diagName);
            }else{
                money = $('#money_num').text();
            }
            $('#money_num').html(money);

            location.href = "../myCenter/diagnosis_money.html?allMoney="+money;
        });

        $('#choosePeople').on('click', function () {
            location.href = "../addPeople/contactPeople.html"
        });

        $('#hospitalDetail').on('click', function () {
            history.go(-1);
        });
        $('#back').on('click', function () {
            history.back();
        });
    });

</script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js" type="text/javascript"></script>
<script src="../js/weixin2.js"></script>
</body>
</html>